package com.cjjd.c.feature.subscribe.nomal_hotel;

import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.cjjd.c.R;
import com.cjjd.c.base.MyBaseAdapter;
import com.cjjd.c.bean.subscribe.NomalBean;
import com.cjjd.c.utils.ImageUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * ----------------------------------
 * Created by xyd on 2017/12/14.
 * <p/>
 * 描  述：
 * <p/>
 * 修订历史:
 * ----------------------------------
 */

public class HotelNomalListviewAdapter extends MyBaseAdapter {

    public HotelNomalListviewAdapter(FragmentActivity mContext) {
        super(mContext);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_hotel_nomal, parent, false);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        NomalBean itemBean = (NomalBean) getItem(position);

        ImageUtil.displayImage(itemBean.picPath,viewHolder.ivHotelLogo);
        viewHolder.tvHotelName.setText(itemBean.hotelName);
        viewHolder.tvHotelAddress.setText(itemBean.hotelAddress);
        viewHolder.tvArrivedTime.setText("住过"+itemBean.livedCount+"次");


        return convertView;
    }


    static class ViewHolder {
        @Bind(R.id.iv_hotel_logo)
        ImageView ivHotelLogo;
        @Bind(R.id.tv_hotel_name)
        TextView tvHotelName;
        @Bind(R.id.tv_hotel_address)
        TextView tvHotelAddress;
        @Bind(R.id.tv_arrived_time)
        TextView tvArrivedTime;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
